<script type="text/javascript">

var z = z || {};
z.base_cdn_url = '<?php echo m('cdn')->get_base_url();?>';
z.base_site_url = '<?php echo m('app')->get_base_url();?>';

z.cdn_url = function (re_url, protocol) {
    protocol = (protocol) ? protocol : 'http';
    return protocol + '://' + z.base_cdn_url + '/' + re_url;
};
z.site_url = function (re_url, protocol) {
    protocol = (protocol) ? protocol : 'http';
    return protocol + '://' + z.trim(z.base_site_url, '/') + '/' + re_url;
};
z.get_current_node_id = function () {
    var hidden = document.getElementById('current_node_id');
    if (hidden) return hidden.value;
    else return false;
};
z.set_current_node_id = function (node_id) {
    var hidden = document.getElementById('current_node_id');
    if ( ! hidden) {
        hidden.document.createElement('input');
        hidden.id = 'current_node_id';
        hidden.type = 'hidden';
        document.body.appendChild(hidden);
    }
    hidden.value = node_id;
};
z.add_node = function (href) {
    var current_node_id = z.get_current_node_id();
    if (current_node_id) {
        href += '&parent_id=' + current_node_id;
    }
    window.location = href;
    return false;
};
z.cdn_img = function (params, callback) {
    params = params || {};
    src = params.src || 'img/icon/blueprint.png';
    width = params.width || 0;
    height = params.height || 0;
    var request_url = z.site_url("?m=cdn&a=img&method=ajax&src="
             + src + "&width=" + width + "&height=" + height);
    z.net.get(request_url, null, function (xhr) {
        var obj = {};
        obj.src = xhr.responseText;
        callback.call(obj);
    });
}
</script>
